/*
 * Copyright (c) 2006 - 2022, webrx.cn All rights reserved.
 *
 */
package cn.demo;

import java.util.stream.Stream;

/**
 * <p>Project: app2022 - Stream3
 * <p>Powered by webrx On 2022-01-26 11:50:01
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Stream3 {
    public static void main(String[] args) {
        var is = Stream.of(1, 8, 2, 9, 15, 12, 9, 9, 9, 96, 0, 4, 0, 22, 11);
        //System.out.println(is.distinct().count());
        //is.skip(3).limit(5).distinct().filter(e -> e % 2 != 0).map(e -> e + 5).forEach(e -> System.out.printf("%d \t", e));

        //并行流 parallelStream其实就是一个并行执行的流.它通过默认的ForkJoinPool,可能提高你的多线程任务的速度.
        Stream.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15).parallel().forEach(System.out::println);
        Stream.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15).parallel().forEachOrdered(System.out::println);

        //串行流
        Stream.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15).forEach(System.out::println);

    }
}
